import {Descriptions} from 'antd';
import {getMeetByIdList} from '../../../../api/client/client.js'
import {useEffect, useState} from "react";
import {useLocation} from "react-router-dom";
import dayjs from "dayjs";

const Detail = () => {
    const {state} = useLocation()
    const [items, setItems] = useState([])

    useEffect(() => {
        getMeetDetail()
    }, [])

    const getMeetDetail = async () => {
        console.log(state, 'state')
        const res = await getMeetByIdList(state.id)
        if (res.code === 200) {
            setItems([
                {
                    key: '1',
                    label: '名称',
                    children: res.data.name ? res.data.name : '-',
                },
                {
                    key: '2',
                    label: '容量',
                    children: res.data.capacity ? res.data.capacity : '-',
                },
                {
                    key: '3',
                    label: '位置',
                    children: res.data.location ? res.data.location : '-',
                },
                {
                    key: '4',
                    label: '设备',
                    children: res.data.equipment ? res.data.equipment : '-',
                },
                {
                    key: '5',
                    label: '备注',
                    children: res.data.description ? res.data.description : '-',
                },
                {
                    key: '6',
                    label: '创建时间',
                    children: res.data.createTime ? dayjs(res.data.createTime).format("YYYY-MM-DD HH:mm:ss") : '-',
                },
            ])
        }
    }

    return (
        <>
            <Descriptions title="会议室详情" items={items}/>
        </>
    )
}

export default Detail